#! /usr/bin/awk -f

BEGIN {
  time_dequeue = 0.0;
  total_time_service = 0.0;
  time_simulation = 0.0;
  counter_packet = 0;
}

{
  action = $1;
  time = $2;
  src = $3;
  dst = $4;
  name = $5;
  size = $6
  flow_id = $8;
  src_address = $9;
  dst_address = $10;
  seq_no = $11;
  packet_id = $12; 

  if (action == "-") {
	time_dequeue = time;
	time_simulation = time;
	counter_packet += 1;
  }

  if (action == "r") {    
  	total_time_service += time - time_dequeue;
	time_simulation = time;
	counter_packet += 1;
  }
#calculate k_util chaque 1 (can modify) packet
if(counter_packet >=1){
	k_util = total_time_service / time_simulation;
	  print time " " k_util > "charge_awk.txt";
	counter_packet = 0;
}
}

END {
}

